package cn.jsj.finance.bank;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 修改工资信息处理类
 * @author LI
 *
 */
 public class ModifyWageInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("修改工资信息！");
		 //输出流
         java.io.PrintWriter out=response.getWriter();

		 //新建工资信息类
		 cn.jsj.pojo.TblWageManage twm=new cn.jsj.pojo.TblWageManage();
		 //赋值
		 twm.setWageId(Integer.parseInt(request.getParameter("mwageId").trim()));
		 twm.setWageTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("mwageTime").trim()));
		 twm.setWageIncome(Integer.parseInt(request.getParameter("mwageIncome").trim()));
		 twm.setWagePayout(Integer.parseInt(request.getParameter("mwagePayout").trim()));
		 //根据律师助理姓名获得ID
		 cn.jsj.dao.TblLawyAssistantDAO tlad=new cn.jsj.dao.TblLawyAssistantDAO();
		 int lawyerAssId=tlad.getLawyerAssistId(request.getParameter("mwageLawyerAssis").trim());
		 //如果不存在这样的律师助理
		 if(lawyerAssId==0){
			 out.println("{message:'不存在这样的律师助理！'}");
			 out.flush();
			 out.close();
			 return;
		 }
		 twm.setLawyAssistantId(lawyerAssId);
         twm.setEnterWagePer(request.getParameter("menterWagePer").trim());
         twm.setWageBrief(request.getParameter("mwageBrief").trim());

         //更新工资信息
         cn.jsj.dao.TblWageManageDAO twmd=new cn.jsj.dao.TblWageManageDAO();
         int updateResult=twmd.updateWageInfo(twm);

         //如果更新成功
         if(updateResult==1){
        	 out.println("{message:'更新成功！'}");

         }else{
        	 out.println("{message:'更新失败！'}");
         }
         out.flush();
         out.close();
	}
}